using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using System.Xml;
using System.Diagnostics;

namespace IWCommunity.Blogs.WebControls
{
    public class List : XmlBasedControl
    {
        private string _listName;

        public string ListName
        {
            get { return _listName; }
            set { _listName = value; }
        }

        protected override System.Xml.XmlDocument BuildDocument()
        {
            try
            {
                SPList oList = Web.Lists[ListName];
               return CleanXml(oList.GetItems(oList.DefaultView).Xml); 
                //return CleanXml(oList.Items.Xml);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);

                XmlDocument oError = new XmlDocument();
                oError.LoadXml(string.Format("<Error>{0}</Error>", ex.Message));
                return oError;
            }
        }
    }
}
